cmake_minimum_required(VERSION 3.14)
project(MMF_BASE LANGUAGES CXX)


set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)

if(WIN32)
    add_definitions(
        -DWIN32
        -D_WIN32_WINNT=0x0A00
        -DYAML_CPP_STATIC_DEFINE
        -D_CRT_SECURE_NO_WARNINGS
    )
else(LINUX)
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()

include_directories(../Third/yaml/include/)     #yaml-cpp
include_directories(../Third/boost_1_82_0_build/include/boost-1_82/) #boost
include_directories(../Third/uWebSocket/uWebSockets/uSockets/src/)
include_directories(../Third/uWebSocket/uWebSockets/src/)

add_library(
    mmf_base STATIC
    ./Concurrency/MutexInterface.hpp
    ./Concurrency/Mutex.hpp
    ./Concurrency/SpinLock.hpp
    ./Concurrency/SpinWaitLock.hpp
    ./Concurrency/Lock.hpp
    ./Concurrency/CycleQueue.hpp
    ./Concurrency/MPMCQueue.hpp

    ./Framework/DataTypeDef.hpp
    ./Framework/Device.hpp
    ./Framework/Component.hpp
    ./Framework/Component.cpp
    ./Framework/UnitConvert.hpp
    ./Framework/UIComponent.hpp

    ./Tools/DllLoader.hpp
    ./Tools/DllLoader.cpp
    ./Tools/DeviceHelper.hpp
    ./Tools/DeviceHelper.cpp
    ./Tools/ProcessTools.hpp
    ./Tools/ProcessTools.cpp
    ./Tools/B_Spline/Fragment.hpp
    ./Tools/B_Spline/Fragment.cpp
    ./Tools/B_Spline/Curve.hpp
    ./Tools/B_Spline/Curve.cpp
    ./Tools/B_Spline/HermiteFrag.hpp
    ./Tools/B_Spline/HermiteFrag.cpp
    ./Tools/B_Spline/HerminteCurve.hpp
    ./Tools/B_Spline/HerminteCurve.cpp
    ./Tools/ObjectPool.hpp
    ./Tools/SceneObject.hpp
    ./Tools/Mesh/ImageInterface.hpp
    ./Tools/Mesh/Image2Mesh.hpp
    ./Tools/Mesh/Image2Mesh.cpp
    ./Tools/Mesh/SigImgReal.hpp
    ./Tools/Mesh/SigImgCpx.hpp
    ./Tools/Mesh/MeshSerialize.hpp
    ./Tools/Mesh/MeshSerialize.cpp
    

    #./Config/CfgDefine.hpp
    #./Config/CfgParseTools.hpp
    #./Config/CfgParseTools.cpp
    #./Config/UnitConfig.hpp
    #./Config/UnitConfig.cpp
    #./Config/ServerConfig.hpp
    #./Config/ServerConfig.cpp
    #./Config/ConponentMeshParser.hpp

    ./BufferPool/BufferPoolInterface.hpp
    ./BufferPool/HostMemPool.hpp
    ./BufferPool/HostMemPool.cpp

    ./Network/NetworkDef.hpp
    ./Network/Session.hpp
    ./Network/Session.cpp
    ./Network/Server.hpp
    ./Network/Server.cpp
    ./Network/DispatchInterface.hpp
    ./Network/BinaryDispatch.hpp
    ./Network/BinaryDispatch.cpp
    ./Network/Client.hpp
    ./Network/Client.cpp
    ./Network/WsDispather.hpp
    ./Network/WsService.hpp

    ./Malloc/TypesDef.hpp
    ./Malloc/MemItem.hpp
    ./Malloc/MemItem.cpp
    ./Malloc/Allocator.hpp
    ./Malloc/Allocator.cpp
    ./Malloc/ThreadAllocator.hpp
    ./Malloc/ThreadAllocator.cpp
    ./Malloc/MemoryPool.hpp
    ./Malloc/MemoryPool.cpp

    ./Logger/Buffer.hpp
    ./Logger/Buffer.cpp
    ./Logger/Logger.hpp
    ./Logger/Logger.cpp

    ./AppComponent/AppBase.hpp
    ./AppComponent/AppComponent.hpp

    ./Serialize/SerialBuffer.hpp
    ./Serialize/SerialBuffer.cpp
    ./Serialize/SerialVector.hpp
    ./Serialize/SerialMap.hpp

    ./TesMath/TesVector2.h
    ./TesMath/TesVector3.h
    ./TesMath/TesVector4.h
    ./TesMath/TesQuaternion.h
    ./TesMath/TesQuaternion.cpp
    ./TesMath/TesEuler.h
    ./TesMath/TesEuler.cpp
    ./TesMath/TesMatrix2x2.h
    ./TesMath/TesMatrix2x2.cpp
    ./TesMath/TesMatrix3x3.h
    ./TesMath/TesMatrix3x3.cpp
    ./TesMath/TesMatrix4x4.h
    ./TesMath/TesMatrix4x4.cpp
    ./TesMath/TesMesh.h
    ./TesMath/TesLinespace.h
    ./TesMath/TesInterpolation.h
    ./TesMath/TesLineInterpolation.h
    ./TesMath/TesLineInterpolation.cpp

    # ./Protocol/AppMessage.h
    # ./Protocol/AppMessage.hpp
    # ./Protocol/AppMessage.cpp
)

#yaml库得导入
#CMAKE_BUILD_TYPE  Debug Release ........
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_directories(mmf_base PRIVATE ../Third/yaml/build/Debug/)
else()
    target_link_directories(mmf_base PRIVATE ../Third/yaml/build/Release/)
endif()
target_link_libraries(mmf_base yaml-cpp)

#unix平台需要引入pthread, linux 或者 macos
if(UNIX)
target_link_libraries(mmf_base pthread)
endif()
